package com.xhx.moduledevelop.jdkspi;

import java.util.HashMap;
import java.util.ServiceLoader;

import com.xhx.moduledevelop.MessagePlugin;

public class SpiTest {

	public static void main(String[] args) {
		// 需要添加spi配置文件 src/main/resources/META-INF/services/com.xhx.moduledevelop.jdkspi.MessagePlugin
		ServiceLoader<MessagePlugin> loader = ServiceLoader.load(MessagePlugin.class);
		// 从上下文里面加载对象
		for (MessagePlugin plugin : loader) {
			plugin.send(new HashMap<>());
		}
	}

}
